// 创建路由
const router = require('express').Router()
// 引入数据库
const db = require('../db')

// 查询商品详情
router.get(`/goodsDetail/:id(\\d+)`, (req, res) => {
    let pid = req.params.id
    let sql = `SELECT * FROM home_tabbar_goods h,goods_details g WHERE g.goods_id = h.id AND h.id = ${pid}`
    db.query(sql, (err, data) => {
        if (err) {
            res.json({
                'ok': 0,
                'error': error
            })
        } else {
            res.json({
                'ok': 1,
                'data': data
            })
        }
    })
})

// 暴露路由
module.exports = router